<template>
	<view>
		<u-navbar placeholder fixed autoBack border title="选择班组"></u-navbar>

		<view class="d-p-30">
			<!-- <view class="d-m-b-20 d-flex">
				<text class="d-font-36 d-flex-1" style="font-weight: bold;">班组列表</text>
				<view class="d-font-28 d-flex" style="color: #ADB4BD;">
					<text class="d-m-r-10">企业筛选</text>
					<u-icon name="arrow-down" color="#5D6672" size="28rpx"></u-icon>
				</view>
			</view> -->
			<view class="card d-p-30 d-m-b-30" v-for="(item, index) in list" :key="index" @click="back(item)">
				<view class="d-font-32 d-m-b-20" style="font-weight: bold;color: #151C24;">{{ item.bzmc }}</view>
				<view class="d-flex" style="color: #5D6672;">
					<view class="d-font-24" style="flex: 3;">
						<text style="">班组长</text>
						<text class="d-m-l-20" style="color: #162233;">{{ item.bzzxm }}</text>
					</view>
					<view class="d-font-24 d-flex" style="flex: 3;">
						<text class="d-m-r-20">联系电话</text>
						<!-- 这里到时候阻止冒泡 -->
						<u--text color="#21A5F3" size="24rpx" mode="phone" :text="item.bzzlxdh"></u--text>
					</view>
				</view>
				<view class="d-flex d-m-t-20" style="color: #5D6672;">
					<view class="d-font-24" style="flex: 3;">
						<text style="">所属单位</text>
						<text class="d-m-l-20" style="color: #162233;">{{ item.deptName }}</text>
					</view>
					<view class="d-font-24" style="flex: 3;">
						<text style="">班组人数</text>
						<text class="d-m-l-20" style="color: #162233;">{{ item.cyrs }}人</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { groups, modifygroupDetail } from '../../../common/api.js';
export default {
	data() {
		return {
			list: [],
			pageSize: 20,
			pageNum: 1,
			pageLast: 1
		};
	},
	onLoad() {
		this.init();
	},
	onReachBottom() {
		if (this.pageNum < this.pageLast) {
			++this.pageNum;
			this.getData().then(e => {
				this.list = this.list.concat(e.data);
			});
		}
	},
	methods: {
		init() {
			this.pageNum = 1;
			this.getData().then(e => {
				this.list = e.data;
				this.pageLast = Math.ceil(e.total / this.pageSize);
			});
		},
		getData() {
			return groups({
				params: {
					gcbh: this.$user.ssgcxx[this.$appIndex].gcbh, // 所属项目编号
					deptId: this.$user.ssgcxx[this.$appIndex].deptId, // 所属部门编号
					pageNum: this.pageNum,
					pageSize: this.pageSize
				}
			});
		},
		back(item) {
			if (uni.getStorageSync('dgry')) {
				modifygroupDetail({
					id: uni.getStorageSync('dgry').id,
					taggroupid: item.id
				}).then(e => {
					uni.$u.toast('操作成功');
					uni.$u.route({
						type: 'back'
					});
				});
			} else {
				uni.setStorageSync('bz', item);
				uni.$u.route({
					type: 'back'
				});
			}
		}
	}
};
</script>

<style lang="scss">
.card {
	box-shadow: 0rpx 5rpx 10rpx rgba(0, 0, 0, 0.05);
	border-radius: 10rpx;
	background-color: #ffffff;
}
page {
	background-color: #fbfcfc;
}
</style>
